# modules/squid/manifests/init.pp - manage squid stuff
# Copyright (C) 2007 admin@immerda.ch
#

# modules_dir { "nfs": }

class nfs_server {

        package { "nfs-utils":
                ensure => installed,
        }

        service { [ "nfs", "nfslock", "portmap"]:
                ensure => running,
                enable => true,
                require => Package["nfs-utils"],
        }

}

define share_dirs($share_root) {

        file { "${share_root}/$name":
                ensure => directory,
                owner => "root",
                group => "root",
                mode => 755,
        }

}

define share_mounts($share_root, $volgroup) {

        mount { "${share_root}/$name":
                ensure => mounted,
                device => "${volgroup}/$name",
                atboot => true,
                fstype => "ext3",
                options => "defaults,nosuid",
                require => File["${share_root}/$name"],

        }

}

define nfs_share ($shares, $volgroup = "", $share_access = "*.$domain", $share_options = "rw,sync") {

        include nfs_server

        share_dirs { $shares: share_root => $name }                             # $shares is an array
#        share_mounts { $shares: share_root => $name, volgroup => $volgroup }    # $shares is an array

        file { "/etc/exports":
                owner => "root",
                group => "root",
                mode => 644,
                content => template("nfs/etc-exports.tpl"),
                notify => Service["nfs"],
        }
}

